import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import menus from './menu'
import AboutView from '../views/AboutView.vue' // 确保导入AboutView组件

const routes = [
    // 基础路由
    {
        path: "/",
        redirect: "/login"
    },
    {
        path: "/login",
        name: "login",
        component: () => import("../views/Login.vue")
    },
    {
        path: "/register",
        name: "register",
        component: () => import("../views/Register.vue")
    },
    {
        path: "/home",
        name: "home",
        component: HomeView,
        children: menus,
         meta: {
             title: '首页',
             icon: 'House', // Element Plus 图标名
            top: true  
         }
    },
    // 添加about路径
    {
        path: "/about",
        name: "about",
        component: () => import('../views/AboutView.vue')
    },
    // 新增个人中心路由（放在这里）
    {
        path: "/user/profile",
        name: "UserProfile",
        component: () => import("@/views/User/Profile.vue") // 动态导入
    }
    
]

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes
})
router.beforeEach((to, from, next) => {
    console.log('路由前置导航守卫==', to, from)
    next()

})

export default router
